from __future__ import annotations

from dataclasses import dataclass
from datetime import datetime
from typing import List, Dict

from quantcore.cost import CostModel


@dataclass
class OrderGenerator:
    cost: CostModel

    def generate(self, picks: List[Dict]) -> List[Dict]:
        orders: List[Dict] = []
        for pick in picks:
            price = float(pick["price"])
            qty = int(pick.get("qty", 100))
            side = pick.get("side", "BUY")
            cost_est = self.cost.estimate_trade_cost(price, qty, side)
            orders.append(
                {
                    "_id": None,
                    "create_time": datetime.utcnow(),
                    "symbol": pick["symbol"],
                    "side": side,
                    "order_type": "LIMIT",
                    "price": price,
                    "qty": qty,
                    "status": "NEW",
                    "cost_estimate": cost_est,
                }
            )
        return orders




